import {isArr} from "@/utils/arrayUtil";

const MENU_TYPE = {
  //  超链接
  HYPERLINK: 'hyperlink',
  //  超链接
  CATALOG: 'catalog',
  //  超链接
  MENU: 'menu',
  //  子页面
  INFO: 'info',
}

const LOGICAL = {
  AND: 'and',
  OR: 'or'
}


/**
 * 检查状态
 * @type {{draft: string, official: string}}
 *
 * draft：草稿
 * official：正式
 */
const INSPECT_STATE = {
  draft: '1',
  official: '2',
  offTheStocks: '3'
}

/**
 * 页面类型
 * @type {{EDIT: string, INFO: string}}
 *
 * EDIT：编辑页
 * INFO：详情页
 */
const PAGE_TYPE = {
  EDIT: 'editPage',
  INFO: 'info'
}

/**
 * 隐患状态
 * @type {{draft: string, official: string}}
 */
const QUESTION_STATE = {
  draft: '0',
  official: '1'
}

/**
 * 按钮类型
 * @type {{}}
 */
const BT_TYPE = {
  primary: 'primary',
  warning: 'warning',
  danger: 'danger',
  text: 'text',
  success: 'success'
}

const OPERATE_TYPE = {
  ADD: 'add',
  UPDATE: 'update'
}

const dict = {
  nodeStateType: [
    {
      label: '未开始',
      value: '1'
    },
    {
      label: '进行中',
      value: '2'
    },
    {
      label: '完成',
      value: '3'
    },
    {
      label: '终止',
      value: '4'
    },
  ],
  acceptStateType: [
    {
      label: '未应答',
      value: '1'
    },
    {
      label: '已接收',
      value: '2'
    },
    {
      label: '已拒绝',
      value: '3'
    },
    {
      label: '商讨中',
      value: '4'
    },
  ]
}

const getEmuDictLabel = (dictType, value) => {
  let cItem = dict[dictType]
  if (!isArr(cItem)) return ''
  let dItem = cItem.find(item => item.value == value);
  return (dItem || {}).label
}

const CHECK_STATE = {
  // 草稿
  DRAFT: '1',
  //   进行中
  UNDERWAY: '2',
  //   已归档
  HAVE_BEEN_FILED: '3',
};

const HIDDEN_DANGER_WIDTH = '80%'

const ORG_TYPE = {
  //   全部
  ALL: '0',
  //  监管部门
  JG: '1',
  //  企业
  QY: '2',
}

// 表格对齐方式
const TABLE_ALIGN = {
  LEFT: 'left',
  CENTER: 'center',
  RIGHT: 'right',
}

// 表格数据显示方式
const TABLE_SHOW_TYPE = {
  // 文字
  TXT: 'txt',
  // 状态灯
  STATE: 'state',
  // 进度条
  SCHEDULE: 'schedule'
};

const COLOR_CONFIG = {
  GREEN: '#67C23A',
  ORANGE: '#E6A23C',
  RED: '#F56C6C',
  BLUE:'#409EFF',
  PINK:'#F5CCFF',
  YELLOW:'#887808'
}

// 隐患整改状态
const QUESTION_REPAIR_CONSTANTS = {
  //  未整改
  NO_REPAIR: '1',
  //  整改中
  REPAIRING: '2',
  //  整改完成
  COMPLETED_REPAIR: '3',
  //  待确认
  TO_BE_CONFIRMED: '4',
};

// 隐患整改状态颜色
const QUESTION_REPAIR_COLOR = [
  // 未整改
  {
    values: [QUESTION_REPAIR_CONSTANTS.NO_REPAIR],
    color: COLOR_CONFIG.RED
  },
  // 整改中
  {
    values: [QUESTION_REPAIR_CONSTANTS.REPAIRING],
    color: COLOR_CONFIG.ORANGE
  },
  // 整改完成
  {
    values: [QUESTION_REPAIR_CONSTANTS.COMPLETED_REPAIR],
    color: COLOR_CONFIG.GREEN
  },
  // 待确认
  {
    values: [QUESTION_REPAIR_CONSTANTS.TO_BE_CONFIRMED],
    color: COLOR_CONFIG.YELLOW
  },
]

// 隐患复核状态
const DEFECT_SCENE_STATE_CONSTANTS = {
  //  未整改
  NO_REPAIR: '1',
  //  未上报
  REPAIRING: '2',
  //  复核中
  CHECKING: '3',
  //  待复核
  WAIT_CHECK: '4',
  //  已复核
  CHECKED: '5',
  //  复核通过
  ENTERPRISE_LEADER_CHECK_OK: '6',
  // 监管部门初审 -- 复核通过
  SUPERVISE_LEADER_CHECK_OK: '7',
  // 监管部门领导复审通过 -- 复核通过
  SUPERVISE_LEADER_CHECK_FS_OK: '11',
  // 监管部门初审 -- 退回
  SUPERVISE_BACKED: '8',
  // 企业领导 -- 退回
  ENTERPRISE_BACKED: '9',
  // 监管部门领导复审退回 -- 退回
  SUPERVISE_BACKED_FS: '10',
};

// 隐患复核状态颜色
const DEFECT_SCENE_STATE_COLOR = [
  // 未整改
  {
    values: [DEFECT_SCENE_STATE_CONSTANTS.NO_REPAIR,DEFECT_SCENE_STATE_CONSTANTS.REPAIRING,],
    color: COLOR_CONFIG.RED
  },
  // 复核中
  {
    values: [DEFECT_SCENE_STATE_CONSTANTS.CHECKING],
    color: COLOR_CONFIG.BLUE
  },
  // 待复核
  {
    values: [DEFECT_SCENE_STATE_CONSTANTS.WAIT_CHECK],
    color: COLOR_CONFIG.YELLOW
  },
  // 已复核/复核通过
  {
    values: [DEFECT_SCENE_STATE_CONSTANTS.CHECKED,DEFECT_SCENE_STATE_CONSTANTS.ENTERPRISE_LEADER_CHECK_OK,DEFECT_SCENE_STATE_CONSTANTS.SUPERVISE_LEADER_CHECK_OK,DEFECT_SCENE_STATE_CONSTANTS.SUPERVISE_LEADER_CHECK_FS_OK],
    color: COLOR_CONFIG.GREEN
  },
  // 退回
  {
    values: [DEFECT_SCENE_STATE_CONSTANTS.SUPERVISE_BACKED,DEFECT_SCENE_STATE_CONSTANTS.ENTERPRISE_BACKED,DEFECT_SCENE_STATE_CONSTANTS.SUPERVISE_BACKED_FS],
    color: COLOR_CONFIG.ORANGE
  },
]

const NODE_TYPE = {
  PARENT:'0',
  LEAF:'1'
}

// 整改状态
const SCENE_STATE = [
  {label:'待复核 ',value:'4'},
  {label:'复核通过 ',value:'6'},
  {label:'退回 ',value:'9'},
]

export {
  getEmuDictLabel,
  CHECK_STATE,
  OPERATE_TYPE,
  BT_TYPE,
  MENU_TYPE,
  LOGICAL,
  INSPECT_STATE,
  PAGE_TYPE,
  QUESTION_STATE,
  HIDDEN_DANGER_WIDTH,
  ORG_TYPE,
  TABLE_ALIGN,
  QUESTION_REPAIR_CONSTANTS,
  TABLE_SHOW_TYPE,
  DEFECT_SCENE_STATE_CONSTANTS,
  QUESTION_REPAIR_COLOR,
  DEFECT_SCENE_STATE_COLOR,
  COLOR_CONFIG,
  NODE_TYPE,
  SCENE_STATE
}
